<table class="biddinger-list" data-page="${page}" data-page-size="${pageSize}" data-count="${count}">
	<tr class="title-row">
		<th class="text-center">单位名称</th>
		<th class="text-center">地址</th>
		<th class="text-center">邮编</th>
		<th class="text-center">网址</th>
		<th class="text-center">配置单位</th>
	</tr>
	<#if data??> <#list data as d>
	<tr data-id="${d[0].id}">
		<td class="">${(d[0].company)!'-'}</td>
		<td class="text-center">${(d[0].addr)!'-'}</td>
		<td class="text-center">${(d[0].zip)!'-'}</td>
		<td class="text-center">${(d[0].url)!'-'}</td>
		<td class="text-center">${(d[1].name)!'-'}</td>
	</tr>
	</#list> </#if>
</table>

<script src="${request.contextPath}/core/js/jquery.form.js"></script>
<script src="${request.contextPath}/js/suredy-list.js"></script>
<script src="${request.contextPath}/app/js/form-checker.js"></script>
<script type="text/javascript">
	$(function() {
		$('.biddinger-list').list({
			search : false,
			checkbox : true,
			paginate : function(page, pageSize, key) {
				$.suredy.loadContent('${request.contextPath}/config/biddinger/list?page=' + page + '&pageSize=' + pageSize);
			},
			btns : [ {
				text : '新建',
				icon : 'icon-edit',
				style : 'btn-primary btn-sm',
				click : function(page, pageSize, key) {
					$.suredy.showModal({
						icon : 'icon-plus',
						title : '新建客户单位',
						uri : '${request.contextPath}/config/biddinger/create?admin=true',
						okClick : function() {
							var form = $('form.form-add-biddinger');

							// 校验表单
							if (!$.suredy.formChecker(form)) {
								return false;
							}

							form.ajaxSubmit({
								success : function(data, textStatus, jqXHR) {
									if (!data) {
										alert('增加建设单位失败！');
										return false;
									}

									$.suredy.loadContent('${request.contextPath}/config/biddinger/list');
									$.suredy.closeModal();
								},
								error : function(jqXHR, textStatus, errorThrown) {
									alert('增加建设单位失败！\n' + errorThrown);
									return false;
								}
							});
						}
					});
				}
			}, {
				text : '删除',
				icon : 'icon-edit',
				style : 'btn-danger btn-sm',
				click : function(page, pageSize, key) {
					var checked = $.suredy.list.checked($('table.biddinger-list'));

					if (checked.length <= 0) {
						alert('请勾选需要删除的项');
						return false;
					}

					var ids = [];

					checked.each(function(i) {
						var $this = $(this);

						ids[ids.length] = $this.data('id');
					});

					$.ajax({
						url : '${request.contextPath}/config/biddinger/delete',
						data : {
							ids : ids
						},
						type : 'post',
						dataType : 'json',
						success : function(data) {
							if (!data || !data.success) {
								alert(data.msg || '删除失败！');
								return false;
							}

							$.suredy.loadContent('${request.contextPath}/config/biddinger/list');
						},
						error : function() {
							alert('删除失败！');
						}
					});
				}
			} ]
		});
	});
</script>